package upicgame.utils;

import java.util.regex.Pattern;

/**
 * @program: upicgame
 * @description: 正则表达式验证
 * @author: lhq
 * @create: 2019-12-24 22:14
 */
public class RegexUtils {
	/**
	 * 验证邮箱
	 * @param email
	 * @return 成功返回true,失败返回false
	 */
	public static boolean isEmail(String email){
		if(email.isEmpty()){
			return false;
		}
		String regex = "\\w+@\\w+\\.[a-z]+(\\.[a-z]+)?";
		return Pattern.matches(regex, email);
	}
	public static boolean isPhoneNumber(String phoneNumber){
		String regex = "^1\\d{10}$";
		return Pattern.matches(regex,phoneNumber);
	}
	public static boolean isNoChineseUsername(String username){
		String regex = "^[A-Za-z0-9]+$";
		return Pattern.matches(regex,username);
	}
	public static boolean isUsername(String username){
		String regex = "^[\\u4E00-\\u9FA5A-Za-z0-9_]+$";
		return Pattern.matches(regex,username);
	}

}
